/**
 * Created by Administrator on 2017/5/22 0022.
 */
$(function(){
    var oli=$(".toplist>.bb");
    for(var i=0;i<oli.length; i++){
        $(oli[i]).on({
            mouseenter:function(){
                $(this).css("backgroundColor","#fff").css("box-shadow","0 0 5px #ccc").siblings()
                    .css("backgroundColor","#f5f4f4");
                $(this).children("div").css("display","block").css("box-shadow","0 0 5px #ccc").css("z-index","2");
                $(this).children(".blank").css("display","block");
                $(this).children("div").parent("li").siblings().children("div").css("display","none");

            },
            mouseleave:function(){
                $(this).children("div").css("display","none");
                $(this).css("backgroundColor","#f5f4f4").css("box-shadow","0 0 0px #ccc");
                $(this).children(".blank").css("display","none");
            }
        })
    }
    /*$(".hoverleft").on({
        mouseenter:function(){
            $(this).css("right","5px")
        },
        mouseleave:function(){
            $(this).css("right","0px")
        }
    })*/
    var mydt=$("<dt></dt>");
    $(".banner-list>ul>li").on({
        mouseenter:function(){
            $(this).css("backgroundColor","#323c43");
            $(".banner-list-two").show();//鼠标移入li时显示二级
            var mydl1=$(".list-two-left").children();
            mydl1.remove();
            $(".list-two-right").children("p").siblings().remove();
            var liIndex=$(this).index();//li的索引
            var listIndex=$(this).children("h3")[0].innerText;//根据这个索引来获取值左边
            var rightIndex=$(".list-two-right").children("p")[0].innerText;
            $.getJSON("js/banner-list.json",function(data){//提取json里面的数据
                for (var key in data[listIndex]) {//根据这个索引来获取值
                    var mydl=$("<dl></dl>");//创建一个dl
                    var mydt=$("<dt>"+key+"</dt>");//创建一个dt
                    $(mydl).append(mydt);//dt在dl里面
                    $(".list-two-left").append(mydl);//再把dl添加到二级菜单
                    for (var i = 0; i < data[listIndex][key].length; i++) {
                        var mydd=$("<dd>"+data[listIndex][key][i]+"</dd>");//创建dd
                        $(mydl).append(mydd);//把dd添加到dl里面
                    }
                }
                var myimg=$("<img src=''/>");//创建右边的img
                myimg.appendTo(".list-two-right");
                myimg.attr("src","images/"+data[rightIndex][liIndex]+"")
            })
        },
        mouseleave:function(){
            $(this).css("backgroundColor","#3c4750");
            // $(".banner-list-two").hide();

        }
    })
    $(".banner-wrap-list").on("mouseleave",function () {
        $(".banner-list-two").hide();
    })


})